package it.patamau.bukkit.afk;

/**
 * Track afk status for players (online only)
 * @author Matteo
 *
 */
public class AfkPlayerStat {

	private String name; //the player name
	private Long time; //the last time the player did something
	private String reason;
	private Boolean afk;
	
	public AfkPlayerStat(String name, Long time, String reason){
		this.name = name;
		this.time = time;
		this.reason = reason;
		this.afk = false;
	}
	
	public String getName(){
		return this.name;
	}
	
	public String getReason(){
		return reason;
	}
	
	public void setReason(String reason){
		this.reason = reason;
	}
	
	public long getTime(){
		return time;
	}
	
	public void setTime(long time){
		this.time = time;
	}
	
	public boolean isAfk(){
		return afk;
	}
	
	public void setAfk(boolean afk){
		this.afk = afk;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer(name);
		long dt = (System.currentTimeMillis()-time.longValue())/60000; //get minutes
		sb.append(" ");
		sb.append(Long.toString(dt));
		sb.append(" minutes ago");
		if(reason!=null){
			sb.append(" (");
			sb.append(reason);
			sb.append(")");
		}
		return sb.toString();
	}
}
